/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.gemom.gui;

import com.gemom.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author Yair Diaz
 */
public class Page3Panel extends JPanel{

    JPanel topPanel,panelchartActuaGui,panelnormalActuaItemsGUI;
    JButton buttonPlot;
    ChartActualDataGUI chartActuaGui;
    NormalDistributionItemsGUI normalActuaItemsGUI;
    CovMatrixData covM2;
    CovMatrixGUI covmatrixGUI2;
    
    public Page3Panel()
    {
        String []nameSeries={"Barclays","BT","VodaFone","Rio"};
        chartActuaGui = new ChartActualDataGUI(nameSeries);
        normalActuaItemsGUI = new NormalDistributionItemsGUI(nameSeries);
        covmatrixGUI2= new CovMatrixGUI(nameSeries.length,300,140); 
        
        buttonPlot = new JButton("Obtain share market data");
        
        
        panelchartActuaGui = new JPanel(new BorderLayout());
        panelchartActuaGui.add(BorderLayout.NORTH,chartActuaGui);
        panelchartActuaGui.add(BorderLayout.CENTER,buttonPlot);
        
                
        topPanel = new JPanel(new GridBagLayout()); 
        GridBagConstraints c = new GridBagConstraints();
        Insets inset=new Insets(5,5,5,5);
	c.insets = inset;
        c.gridwidth = 1;c.gridheight = 1;
        c.gridx=0; c.gridy=0;
        topPanel.add(normalActuaItemsGUI,c);
        c.gridx=0; c.gridy=1;
        topPanel.add(covmatrixGUI2,c);
        
        
        
        
        topPanel.setBackground(Color.WHITE);
        this.setLayout(new BorderLayout());
        this.add(BorderLayout.NORTH,panelchartActuaGui);
        this.add(BorderLayout.CENTER, topPanel);
        this.setBackground(Color.WHITE);
        this.setSize(1225,767);
        
        ///////////////////////////////////////
        buttonPlot.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {       
                
               chartActuaGui.showPlot();
               covM2 = new CovMatrixData(chartActuaGui.getSeriesData());
               covM2.calculateMeanAndStdDev();
               covmatrixGUI2.enterCovMatrixData(covM2.getCovMatrix());
               normalActuaItemsGUI.createChartSeries(covM2.getMeanAndStdDev());
               buttonPlot.setEnabled(false);
                        
           }});
        ///////////////////////////////////////   

           
           
        ///////////////////////////////////////
    }
    
 //   public void run(){ }
    
}
